package com.op.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.op.constants.NumberConstant;
import com.op.entity.Question;
import com.op.mapper.QuestionMapper;
import com.op.service.QuestionService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Question)表服务实现类
 *
 * @author 孤焰
 * @since 2021-10-03 16:39:57
 */
@Service("questionService")
public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> implements QuestionService {

    @Resource
    QuestionMapper questionMapper;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean logicDelBatchById(List<Long> idList) {
        for (Long id : idList) {
            Question question = new Question();
            question.setId(id);
            question.setStatus(NumberConstant.DISABLE);
            if (questionMapper.updateById(question) <= 0) {
                throw new RuntimeException("部分删除失败");
            }
        }
        return true;
    }
}

